//
// Created by 王乐 on 2022/2/11.
//

#ifndef LESTE_LECAMERACADBEHAVIOUR_H
#define LESTE_LECAMERACADBEHAVIOUR_H

#include "LeCameraBaseBehaviour.h"

enum CameraMoveState
{
    CMS_NONE,
    CMS_FLY,
    CMS_FOCUS,
    CMS_FLATMOVE,
    CMS_ZOOM
};

class LeCameraCADBehaviour : public LeCameraBaseBehaviour
{
public:
    LeCameraCADBehaviour();
    virtual ~LeCameraCADBehaviour();

    glm::mat4 getViewMatrix() override;
    glm::mat4 getProjectionMatrix() override;

    void Start() override;
    void Update() override;

private:
    void processNoneState();
    void processFlyState();
    void processFocusState();
    void processFlatMoveState();
    void processZoomState();

public:
    // Fly
    void processKeyboard();
    void updateCameraFocus();

    // Focus
    void updateCameraPosition();

    // Common
    void processMouseMovement(float xoffset, float yoffset, bool constrainPitch);
    void processMouseScroll(float yoffset);

    void updateCameraVectors();

public:
    CameraMoveState m_State;

    // common
    float yaw;
    float pitch;
    float zoom;
    float moveSpeed;
    bool bIsPerspectiveView;

    void setIsPerspectiveView(bool bIsPerspectiveView);
    void flipViewType();

    float dLastX;
    float dLastY;

    glm::vec3 Front;
    glm::vec3 Up;
    glm::vec3 Right;
    glm::vec3 WorldUp;

    float focusDistance;
    glm::vec3 Focus;

    // Fly
    float mouseSensitivity;

    //flat move
    float flatMoveSensitivity;

    // Focus


    // For CubicBox
    bool isChanging;
};


#endif //LESTE_LECAMERACADBEHAVIOUR_H
